import { RECOMMEND_IS_DISABLED_LIST } from '@/const/type';
export const tableOption = () => {
  return {
    ...window.$crudMixins.tableOptions,
    addBtn: true,
    addBtnText: '新增推荐',
    editBtn: true,
    delBtn: true,
    menuWidth: 100,
    searchLabelWidth: 120,
    labelWidth: 120,
    column: [
      {
        label: '推荐内容类型',
        prop: 'objType',
        width: 160,
        type: 'select',
        search: true,
        row: true,
        dicData: [
          {
            label: '宠物',
            value: '1',
          },
        ],
        rules: [
          {
            required: true,
            message: '请选择推荐内容类型',
            trigger: 'blur',
          },
        ],
      },
      {
        label: '推荐封面图',
        prop: 'coverImage',
        type: 'upload',
        listType: 'picture-img',
        span: 12,
        fileSize: 10 * 1024,
        row: true,
        width: 80,
        imgFullscreen: true,
        propsHttp: {
          name: 'hash',
          url: 'key',
        },
        fileType: 'img', //img/video/audio
        // action: 'http://upload-z2.qiniup.com',
        oss: 'qiniu',
        // cropperOption: {
        //   enlarge: 2,
        //   fixed: true,
        //   fixedNumber: [0.83, 1],
        // },
        tip: '请上传jpg/png/jpeg/webp/heic类型的文件，最大可上传10M',
        accept: '.jpg,.png,.jpeg,.webp,.heic',
        limit: 1,
        rules: [
          {
            required: true,
            message: '请上传推荐封面图',
            trigger: 'blur',
          },
        ],
      },
      {
        label: '推荐内容',
        prop: 'objName',
        search: true,
        type: 'select',
        searchType: 'input',
        row: true,
        filterable: true,
        clearable: true,
        dicUrl: `/core/shelf/record/list/?param={{key}}`,
        props: {
          label: 'label',
          value: 'value',
        },
        dicFlag: true,
        dicFormatter: (data) => {
          const res = data.data;
          res.forEach((el) => {
            const obj = {
              id: el.id,
              nickname: el.nickName,
            };
            el.label = `${el.nickName}（${el.code}）`;
            el.value = JSON.stringify(obj);
          });
          return res;
        },
        rules: [
          {
            required: true,
            message: '请选择推荐内容',
            trigger: 'blur',
          },
        ],
      },
      {
        label: '排序',
        prop: 'sort',
        type: 'number',
        value: 1,
        precision: 0,
        min: 0,
        max: 100,
        width: 100,
        rules: [
          {
            required: true,
            message: '请输入排序',
            trigger: 'blur',
          },
        ],
        row: true,
        span: 12,
      },
      {
        label: '推荐状态',
        prop: 'status',
        type: 'radio',
        rules: [
          {
            required: true,
            message: '请选择推荐状态',
          },
        ],
        width: 160,
        dicData: RECOMMEND_IS_DISABLED_LIST,
      },
      {
        label: '创建时间',
        prop: 'createTime',
        type: 'datetime',
        width: 160,
        format: 'yyyy-MM-dd HH:mm:ss',
        valueFormat: 'yyyy-MM-dd HH:mm:ss',
        addDisplay: false,
        editDisplay: false,
      },
    ],
  };
};
